import {http} from "@/utils/http/axios";
import {storage} from '@/utils/Storage';

export function saveAdmin(username) {
  return http.request({
    url: window.SITE_CONFIG.baseUrl + '/admin',
    headers: {token: storage.get('token')},
    method: 'POST',
    params: {
      username: username,
    },
  });
}

export function deleteAdmin(id) {
  return http.request({
    url: window.SITE_CONFIG.baseUrl + '/admin?id=' + id,
    headers: {token: storage.get('token')},
    method: 'DELETE',
  });
}

export function updateAdmin(id, username, status, roleIds) {
  return http.request({
    url: window.SITE_CONFIG.baseUrl + '/admin',
    headers: {token: storage.get('token')},
    method: 'PUT',
    params: {
      id: id,
      username: username,
      status: status,
      roleIds: roleIds,
    },
  });
}

export function adminPage(params) {
  return http.request({
    url: window.SITE_CONFIG.baseUrl + '/admin/page',
    headers: {token: storage.get('token')},
    method: 'POST',
    params,
  });
}
